package com.googlecode.jtoy.patterns.factory;

/**
 * @author shangxj
 * @date Jun 27, 2011 1:48:59 PM
 */
public class ShapeFactoryImpl implements ShapeFactory {

	@Override
	public Shape make(Class<? extends Shape> clazz) {

		try {
			return clazz.newInstance();
		}
		catch (InstantiationException e) {
			e.printStackTrace();
		}
		catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public Shape make(String shapeClassName) {

		try {
			return (Shape) Class.forName(shapeClassName).newInstance();
		}
		catch (InstantiationException e) {
			e.printStackTrace();
		}
		catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		return null;
	}

}
